﻿Imports Phila
Imports Phila.Sql
Imports Phila.CommonClasses

Public Class Innerpage
    Inherits System.Web.UI.MasterPage

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not IsPostBack = True Then
                If Session("UserID") Is Nothing Then
                    'plMyList.Visible = False
                End If

                Fill_ComboBox(cmbTCat, "select Id, Name from ptn_Countries order by Name")
                additem(cmbTCat, "--Select Country--", 0)
                additem(cmbTZone, "--Select Zone--", 0)
                additem(cmbTour, "--Select Tour--", 0)

                Fill_ComboBox(cmbCountry, "select distinct Country as id, Country from ptn_Hotels where IsActive=1 order by Country")
                additem(cmbCountry, "--Select Country--", 0)
                additem(cmbCity, "--Select City--", 0)
                additem(cmbCategory, "--Select Category--", 0)

                'If LCase(Request.Url.Segments(1)) = "hotels.aspx" Then
                '    plTours.Visible = False
                '    plHotels.Visible = True
                'Else
                '    plHotels.Visible = False
                '    plTours.Visible = True
                'End If
                If LCase(Request.Url.Segments(1)) = "news.aspx" Then
                    plArchiveNews2.Visible = True
                End If

                'fillTestimonials()

                If LCase(Request.Url.Segments(1)) = "hotels.aspx" Then
                    plTours.Visible = False
                    plHotels.Visible = True
                Else
                    plHotels.Visible = False
                    plTours.Visible = True
                End If

                If Session("Breadcrumb") IsNot Nothing Then
                    'ltrBreadcrumb.Text = Session("Breadcrumb")
                    Session("Breadcrumb") = Nothing
                End If
            End If
        Catch ex As Exception
            Throw ex
        End Try
    End Sub



    Protected Sub cmbCountry_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCountry.SelectedIndexChanged
        Fill_ComboBox(cmbCity, "select distinct City as id, City from ptn_Hotels where IsActive=1 and Country='" & cmbCountry.SelectedValue & "' order by City")
        additem(cmbCity, "--Select City--", 0)
    End Sub

    Protected Sub cmbCity_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbCity.SelectedIndexChanged
        Fill_ComboBox(cmbCategory, "select Id, Caption from ptn_HotelCategory where IsActive=1 and Id in (select CategoryId  from ptn_Hotels where City='" & cmbCity.SelectedValue & "')")
        additem(cmbCategory, "--Select Hotels--", 0)
    End Sub

    Protected Sub cmbTCat_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTCat.SelectedIndexChanged
        Dim txt As Array
        'txt = RetriveData("select Id, Name from ptn_Zones where IsActive=1 and CategoryId=" & cmbTCat.SelectedValue & " order by Name", 1)
        txt = RetriveData("select z.Id, z.Name from ptn_Zones z inner join ptn_CatZoneTours cz on cz.ZoneId=z.Id where z.IsActive=1 and cz.CountryId=" & cmbTCat.SelectedValue & " order by Name", 1)
        If Not txt(0) Is Nothing Then
            cmbTZone.Visible = True
            'Fill_ComboBox(cmbTZone, "select Id, Name from ptn_Zones where IsActive=1 and CategoryId=" & cmbTCat.SelectedValue & " order by Name")
            Fill_ComboBox(cmbTZone, "select distinct z.Id, z.Name from ptn_Zones z inner join ptn_CatZoneTours cz on cz.ZoneId=z.Id where IsActive=1 and cz.CountryId=" & cmbTCat.SelectedValue & " order by Name")
            additem(cmbTZone, "--Select Zone--", 0)
            cmbTour.Items.Clear()
            additem(cmbTour, "--Select Tour--", 0)
        Else
            cmbTZone.Visible = False
            'Fill_ComboBox(cmbTour, "select Id, Replace(Name, '&#039;', '`') Name from ptn_Tours where IsActive=1 and CategoryId=" & cmbTCat.SelectedValue & " order by Name")
            Fill_ComboBox(cmbTour, "select t.Id, Replace(t.Name, '&#039;', '`') Name from ptn_Tours t inner join ptn_CatZoneTours ct on ct.tourid=t.Id where t.IsActive=1 and ct.countryid=" & cmbTCat.SelectedValue & " order by Name")
            additem(cmbTour, "--Select Tour--", 0)
        End If
    End Sub

    Protected Sub cmbTZone_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmbTZone.SelectedIndexChanged
        'Fill_ComboBox(cmbTour, "select Id, Replace(Name, '&#039;', '`') Name from ptn_Tours where IsActive=1 and Zoneid=" & cmbTZone.SelectedValue & " order by Name")
        Fill_ComboBox(cmbTour, "select t.Id, Replace(t.Name, '&#039;', '`') Name from ptn_Tours t inner join ptn_CatZoneTours zt on zt.tourid=t.id where t.IsActive=1 and zt.Zoneid=" & cmbTZone.SelectedValue & "  order by Name")
        additem(cmbTour, "--Select Tour--", 0)
    End Sub

    Protected Sub btnHotel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnHotel.Click
        Response.Redirect("Hotels.aspx?city=" & cmbCity.SelectedValue & "&cat=" & cmbCategory.SelectedValue)
        'Response.Redirect("Hotels.aspx?hid=" & cmbCategory.SelectedValue)
    End Sub

    Protected Sub btnTour_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnTour.Click
        Response.Redirect("tours.aspx?tid=" & cmbTour.SelectedValue)
    End Sub

End Class